package org.jeecg.config;

import org.jeecg.access.platform.service.PlatformHandler;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

/**
 * @description: todo
 * @author: taogang
 * @date: 2025/7/31 10:10
 */
@Component
public class PlatformHandlerFactory {
    private final Map<String, PlatformHandler> handlerMap = new ConcurrentHashMap<>();

    @Autowired
    public PlatformHandlerFactory(List<PlatformHandler> handlers) {
        for (PlatformHandler handler : handlers) {
            handlerMap.put(handler.getPlatformType(), handler);
        }
    }

    public Map<String, PlatformHandler> getHandlerMap() {
        return handlerMap;
    }

    public PlatformHandler getHandler(String platformType) {
        return handlerMap.get(platformType);
    }
}
